<?php
/**
 * Created by PhpStorm.
 * User: ye
 * Date: 2017/11/17
 * Time: 下午4:16
 */

namespace App\Http\Controllers;


use App\Jobs\ReceiveGiteeMessage;
use Illuminate\Http\Request;

class GiteeController extends Controller {

    public function issues(Request $request) {

    }

    /*
     * 获取评论内容
     */
    public function notes(Request $request) {
        $noteable_type = $request->input('noteable_type', null);

        if ($noteable_type == null || $noteable_type != 'Issue') {
            return $this->output(400, '不是正确的评论类型');
        }

        $password = $request->input('password', null);

        if ($password == null || $password != config('gitee.apis_xcx_webhook_password')) {
            return $this->output(401, 'password 有误');
        }

        $note = $request->input('note', '');
        $noteable_id = $request->input('noteable_id', -1);
        $per_iid = $request->input('per_iid', '');

        //客服队列
        $job = new ReceiveGiteeMessage($note, $noteable_id, $per_iid);
        dispatch($job);

        return true;
    }

}